package ui;

import Tools.*;

import javax.swing.*;
import java.awt.*;

public class DrawingBoard extends JFrame {
    //引入
    private Bar bar;
    private MyPanel panel;
    private EventHandler eventHandler;
    private StatusManager statusManager;
    private FiguresContainer figuresContainer;
    private PropertyManager propertyManager;
    private Serializer serializer;

    public DrawingBoard(){init();}

    private void init(){
        //创建
        bar = new Bar();
        panel = new MyPanel();
        eventHandler = new EventHandler();
        statusManager = new StatusManager();
        figuresContainer = new FiguresContainer();
        propertyManager = new PropertyManager();
        serializer = new Serializer();



        bar.setPanel(panel);
        bar.setDrawingBoard((DrawingBoard)getParent());
        bar.setEventHandler(eventHandler);


        eventHandler.setBar(bar);
        eventHandler.setStatusManager(statusManager);
        eventHandler.setContainer(figuresContainer);
        eventHandler.setPanel(panel);
        eventHandler.setPropertyManager(propertyManager);
        eventHandler.setSerializer(serializer);


        panel.setEventHandler(eventHandler);
        panel.setStatusManager(statusManager);
        panel.setFiguresContainer(figuresContainer);

        figuresContainer.setStatusManager(statusManager);





        setSize(1000,500);
        setTitle("画板");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //添加绘图MyPanel组件
        add(bar, BorderLayout.NORTH);
        add(panel);




    }

}
